package com.mapper;

import com.bean.Student;
import org.apache.ibatis.annotations.*;

public interface StudentMapperByAnnotation {

    @Select("select * from stu7 where stuno =#{stuno}")
    @Results({@Result(id = true,column = "stuno",property = "stuno"),
    @Result(column = "stuname",property = "stuname"),
    @Result(column = "grade",property = "grade"),
    @Result(column = "dept",property = "dept"),
    @Result(column = "classid",property = "classBean",
            one = @One(select = "com.mapper.ClazzMapperByAnnotation.getClazzById")),


    })
    public Student findStuForClazzByStuno(Integer stuno);



    @Select("select * from stu7 where classid = #{id}")
    public Student findStuForClazzById(Integer id);

    @Select("select * from stu7 where stuno in (select stuno from t_sc where cid=#{cid})")
    public Student findStuForCourseByCid(Integer cid);

    @Select("select * from stu7 where stuno=#{stuno}")
    @Results({
            @Result(id = true,column = "stuno",property = "stuno"),
            @Result(column = "stuname",property = "stuname"),
            @Result(column = "grade",property = "grade"),
            @Result(column = "dept",property = "dept"),
            @Result(column = "stuno",property = "courses",many = @Many(select = "com.mapper.CourseMapperByAnnotation.findCourseByStuno"))

    })
    public Student findCourseForStuByStuno(Integer stuno);
}
